package com.wtwd.campus.chain;


import com.wtwd.campus.common.RespCode;
import com.wtwd.campus.common.RespEntity;

/**
 * @author mjy(H5绑定学生责任链)
 * 该链路器主要针对客户对于家长和设备之间的关系处理
 * 1.湖南和教育h5 1-1
 * @date 2022/04/18
 * @description
 */
public abstract class H5BindDeviceChain {


    /**
     * 瑞翼客户id
     */
    public static Integer RY_CUSTOMER_ID = 5;

    /**
     * 长虹客户id
     */
    public static Integer CH_CUSTOMER_ID=8;

    /**
     * h5的设备类型
     */

    public static Integer H5_DEVICE_TYPE = 3;


    /**
     * 1号链路器执行设备绑定关系判断
     */
    public static int verifyDeviceBind = 1;

    /**
     * 二号链路器执行绑定设备操作
     */
    public static int bindDevice = 2;

    public int level;

    protected H5BindDeviceChain nestDeviceChain;

    public void setNestDeviceChain(H5BindDeviceChain nestDeviceChain) {
        this.nestDeviceChain = nestDeviceChain;
    }

    public RespEntity submitH5BindDevice(int level, Integer h5UserId, String imei, String studentName) {
        if (this.level <= level) {
            RespEntity respEntity = H5BindDevice(h5UserId, imei, studentName);
            if (respEntity.getCode() != RespCode.SUCCESS.getCode()) {
                return respEntity;
            }
        }
        if (nestDeviceChain != null) {
            return nestDeviceChain.submitH5BindDevice(level, h5UserId, imei, studentName);
        }
        return new RespEntity(RespCode.SUCCESS);
    }

    abstract protected RespEntity H5BindDevice(Integer h5UserId, String imei, String studentName);


}
